<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('积分明细列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								姓名：<input type="text" name="realName"/>
							</li>

							<li>
								手机号：<input type="text" name="phone"/>
							</li>
							<li>
								街道：
								<select  id="street"  name="street" th:with="address=${@address.selectAllstreet()}">
									<option selected="selected" disabled="disabled"  style='display: none' value=''></option>
									<option th:each="address : ${address}" th:text="${address.street}" th:value="${address.street}"></option>
								</select>
							</li>
							<li>
								社区：
								<select id="community" name="community" th:with="address=${@address.selectAllcommunity()}">
									<option selected="selected" disabled="disabled"  style='display: none' value=''></option>
									<option th:each="address : ${address}" th:text="${address.community}" th:value="${address.community}"></option>
								</select>
							</li>
							<li>
								小区：
								<select id="village"  name="village" th:with="address=${@address.selectAllvillage()}">
									<option selected="selected" disabled="disabled"  style='display: none' value=''></option>
									<option th:each="address : ${address}" th:text="${address.village}" th:value="${address.village}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:envirBonusTotal:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:envirBonusTotal:remove')}]];
        var prefix = ctx + "system/integral";
		var datas = [[${@dict.getType('sys_user_sex')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                modalName: "积分明细",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
					{
						field : 'id',
						title : '',
						visible: false
					},
					{
						field : 'realName',
						title : '真实姓名'
					},
					{
						field : 'gender',
						title : '性别',
						formatter: function(value, row, index) {
							return $.table.selectDictLabel(datas, value);
						}
					},
					{
						field : 'phone',
						title : '手机号'
					},{
						field : 'city',
						title : '城市'
					},{
						field : 'district',
						title : '区'
					},{
						field : 'street',
						title : '街道'
					},{
						field : 'community',
						title : '社区'
					},{
						field : 'village',
						title : '小区'
					},{
						field : 'historyTotalIntegral',
						sortable: true,
						title : '积分总数'
					}]
            };
            $.table.init(options);
        });
		$("#street").change(function(){
			debugger
			var name = $("#street").val();
			if(name ==''){
				return;
			}
			$.ajax({
				url:'/system/address/selectCommunityBystree?name='+name,
				async:false,
				type:'get',
				success:function(data){
					var t3 = $("#community").empty();
					var t4 = $("#village").empty();
					t3.append("<option selected=\"selected\" disabled=\"disabled\"  style='display: none' value=''></option>");
					t4.append("<option selected=\"selected\" disabled=\"disabled\"  style='display: none' value=''></option>");
					for ( var i = 0; i < data.length; i++) {
						t3.append("<option value='"+data[i].community+"'>"+ data[i].community+"</option>");
						t4.append("<option value='"+data[i].village+"'>"+ data[i].village+"</option>");
					}
				}
			})
		});

		$("#community").change(function(){
			debugger
			var name = $("#community").val();
			if(name ==''){
				return;
			}
			$.ajax({
				url:'/system/address/selectVillageBycommunity?name='+name,
				async:false,
				type:'get',
				success:function(data){
					debugger
					var t3 = $("#village").empty();
					t3.append("<option selected=\"selected\" disabled=\"disabled\"  style='display: none' value=''></option>");
					for ( var i = 0; i < data.length; i++) {
						t3.append("<option value='"+data[i].village+"'>"+ data[i].village+"</option>");
					}
					$("#street").val(data[0].street)
				}
			})
		});


		$("#village").change(function(){
			var name = $("#village").val();
			if(name ==''){
				return;
			}
			$.ajax({
				url:'/system/address/listByVillage',
				async:false,
				type:'post',
				data:{village:name},
				success:function(data){
					$("#street").val(data[0].street)
					$("#community").val(data[0].community)
				}
			})
		});

	</script>
</body>
</html>